package com.seal.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.seal.dao.BaseDaoImpl;
import com.seal.dao.ICityDao;
import com.seal.model.TCity;

@Service("cityDaoImpl")
@Transactional(readOnly = true)
public class CityDaoImpl extends BaseDaoImpl implements ICityDao {

	public List<TCity> getCitysById(String pid,String cid) throws Exception {
		StringBuffer hql = new StringBuffer("from TCity t where 1=1 ");
		if(pid!=null)
			hql.append(" and t.id.pid='" + pid + "'");
		
		if(cid!=null && !"".equals(cid.trim()))
			hql.append(" and t.id.id='" + cid + "'");
		
		Query query = this.getSession().createQuery(hql.toString());
		return query.list();
	}
}
